package com.westvalley.service.api.hr;

import java.util.Map;

import com.google.common.collect.Maps;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.westvalley.common.kit.StringKit;

/**
 * 异动类型判断接口
 * @author 莫双
 *
 */
public class RemoveTypeService extends HrService{
	public static final String KEY = "removeType";
	private Controller ctrl;
	
	public static RemoveTypeService me(Controller ctrl){
		return new RemoveTypeService(ctrl);
	}
	
	private RemoveTypeService(Controller ctrl){
		super(KEY);
		this.ctrl = ctrl;
	}

	@Override
	protected Map<String, String> initParams() {
		Map<String, String> params = Maps.newHashMap();
		Record subCompanyRecord = Db.findFirst("SELECT * FROM HrmSubCompany WHERE ID = ?",ctrl.getPara("inShopId"));		//调入门店编码
		Record departmentRecord = Db.findFirst("SELECT * FROM HrmDepartment WHERE ID = ?",ctrl.getPara("inOfficeId")); 		//调入部门编号
		Record jobTitlesRecord = Db.findFirst("SELECT * FROM HrmJobTitles WHERE ID = ?",ctrl.getPara("dutyId")); 			//调入职务编号
		Record resourceRecord = Db.findFirst("SELECT * FROM HrmResource WHERE ID = ?",ctrl.getPara("employeeId"));			//调动人
		
		if(subCompanyRecord!=null){
			params.put("shopId", StringKit.null2o(subCompanyRecord.get("SUBCOMPANYCODE")));			//门店编码
			params.put("inShopId", StringKit.null2o(subCompanyRecord.get("SUBCOMPANYCODE")));		//调入店编号
		}
		if(departmentRecord!=null){
			params.put("inOfficeId", StringKit.null2o(departmentRecord.get("DEPARTMENTCODE")));		//调入部门编号
		}
		if(jobTitlesRecord!=null){
			params.put("dutyId", StringKit.null2o(jobTitlesRecord.get("JOBTITLECODE")));			//调入职务编号
		}
		if(resourceRecord!=null){
			params.put("employeeId", StringKit.null2o(resourceRecord.get("WORKCODE")));			//员工编码
		}
		params.put("removeFlag", ctrl.getPara("removeFlag"));		//调动标志
		return params;
	}
	
	
}
